<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="body">
    <fieldset>
      <legend>grid</legend>
      <div class="grid-container">
        <div class="main"></div>
      </div>
    </fieldset>
    <fieldset>
      <legend>flex</legend>
      <div class="flex1-container">
        <div class="main"></div>
      </div>
    </fieldset>
    <fieldset>
      <legend>flex</legend>
      <div class="flex2-container">
        <div class="main"></div>
      </div>
    </fieldset>
  </div>
</body>
<style>
  .body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 300px 300px;
  }
  .main {
    height: 100px;
    width: 100px;
    background-color: black;
  }
  .flex1-container {
    height: 100%;
    display: flex;
  }
  .flex2-container {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .flex1-container .main {
    margin: auto;
  }
  .grid-container {
    height: 100%;
    display: grid;
    place-items: center;
  }
</style>
</html>